package org.yoki.edu.common.protocol.portal.msg.attr;

import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Arrays;

/**
 * @author Sky$
 * @Description: TODO
 * @date 2017/10/24$ 20:44$
 */
@Data
public class MsgAttr {

    private int attrType;
    private int attrLen;
    private String attrValue;
    private byte[] byteValues ;

    protected MsgAttr(){

    }

    public MsgAttr(int attrType, String attrValue) {
        this.attrType = attrType;
        this.attrLen = 2 + attrValue.getBytes().length;
        this.attrValue = attrValue;

        byteValues = new byte[attrLen] ;
        byteValues[0] = (byte)attrType ;
        byteValues[1] = (byte)attrLen ;
        System.arraycopy(attrValue.getBytes(), 0, byteValues, 2, attrValue.getBytes().length);
    }

}
